package com.sy.live.service.impl;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.sy.live.dao.IBaseDao;
import com.sy.live.entity.TbVideoLink;
import com.sy.live.service.ILinkService;

@Service("linkService")
public class LinkServiceImpl extends BaseServiceImpl implements ILinkService
{
	@Resource(name = "baseDao")
	private IBaseDao baseDao;
	
	@Override
	public TbVideoLink findRecordByContentAndCategoryId(int categoryId, String content)
	{
		String hql = "from TbLink a where a.categoryId = :categoryId and a.content = :content";
		
		Map<String, Object> paramMap = new HashMap<String, Object>();
		
		paramMap.put("categoryId", categoryId);
		paramMap.put("content", content);
		
		return baseDao.executeUniqueHQL(hql, paramMap);
	}

	@Override
	public TbVideoLink getLastRecordByCategoryId(int categoryId)
	{
		String hql = "from TbLink a where a.categoryId = :categoryId order by a.playTime";
		
		Map<String, Object> paramMap = new HashMap<String, Object>();
		
		paramMap.put("categoryId", categoryId);
		
		return baseDao.executeUniqueHQL(hql, paramMap);
	}

}
